VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "CDXVBInput"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' A (simple) DirectInput class wrapper

Public m_lpDI As IDirectInputA
Public m_lpDIDKeyboard As IDirectInputDeviceA

Private Sub Class_Terminate()
      m_lpDIDKeyboard.UnAcquire
      Set m_lpDIDKeyboard = Nothing
      
      Set m_lpDI = Nothing
End Sub

Public Sub Create(hInst As Long, hWnd As Long)
      Dim res As Long

      DirectInputCreateA ByVal hInst, &H500, m_lpDI, Nothing
      
      m_lpDI.CreateDevice GUID_SysKeyboard, m_lpDIDKeyboard, Nothing
      m_lpDIDKeyboard.SetDataFormat c_dfDIKeyboard
      m_lpDIDKeyboard.SetCooperativeLevel hWnd, DISCL_NONEXCLUSIVE Or DISCL_FOREGROUND
End Sub

Public Sub ReAcquire()
      m_lpDIDKeyboard.Acquire
End Sub

Public Sub UnAcquire()
      m_lpDIDKeyboard.UnAcquire
End Sub

Public Sub UpdateKeyboard()
      m_lpDIDKeyboard.GetDeviceState 256, Keys(0)
      If Err <> 0 Then m_lpDIDKeyboard.Acquire
End Sub
